package ui.components;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;

public class InputTextBox extends JPanel {

	private JLabel label;
	private JTextArea area;

	public InputTextBox(String text, Integer value) {
		label = new JLabel(text);
		label.setPreferredSize(new Dimension(70, 19));
		label.setHorizontalAlignment(SwingConstants.LEFT);
		area = new JTextArea("" + value);
		area.setPreferredSize(new Dimension(50, 19));
		area.setOpaque(true);
		area.setBackground(Color.WHITE);
		area.setBorder(BorderFactory.createLoweredBevelBorder());
		this.setLayout(new FlowLayout());
		this.add(label);
		this.add(area);
	}

	public Integer getValue() {
		return area != null ? Integer.valueOf(area.getText()) : 0;
	}

	// Accessors
	public JLabel getLabel() {
		return label;
	}

	public void setLabel(JLabel label) {
		this.label = label;
	}

	public JTextArea getArea() {
		return area;
	}

	public void setArea(JTextArea area) {
		this.area = area;
	}

}
